﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SystemUpdate
{
    public partial class UseProxyForm : Form
    {
        public bool UseProxy
        {
            get { return this.checkBoxProxy.Checked; }
            set { this.checkBoxProxy.Checked = value; }
        }
        public string ProxyAddress
        {
            get { return this.Address.Text; }
            set { this.Address.Text = value; }
        }
        public bool ProxyAuthenticationIsRequried
        {
            get { return this.checkBoxAccount.Checked; }
            set { this.checkBoxAccount.Checked = value; }
        }
        public string ProxyUser
        {
            get { return this.UserName.Text; }
            set { this.UserName.Text = value; }
        }
        public string ProxyPassword
        {
            get { return this.Password.Text; }
            set { this.Password.Text = value; }
        }

        public UseProxyForm()
        {
            InitializeComponent();
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            
        }

        private void SetState()
        {
            this.Address.Enabled = this.checkBoxProxy.Checked;
            this.checkBoxAccount.Enabled = this.checkBoxProxy.Checked;

            if (this.checkBoxAccount.Enabled)
            {
                this.UserName.Enabled = this.checkBoxAccount.Checked;
                this.Password.Enabled = this.checkBoxAccount.Checked;
            }
            else 
            {
                this.UserName.Enabled = false;
                this.Password.Enabled = false;
            }
        }

        private void checkBoxProxy_CheckedChanged(object sender, EventArgs e)
        {
            SetState();
        }

        private void checkBoxAccount_CheckedChanged(object sender, EventArgs e)
        {
            SetState();
        }
    }
}
